enum FlashMessage {
    Success,
    Warning { category: i32, message: String },
    Error(String) // Tuple
}

/// 测试enum
pub fn test() {
    let mut form_status = FlashMessage::Success;
    print_flash_message(form_status);

    form_status = FlashMessage::Warning { category: 2, message: String::from("Field X is required")};
    print_flash_message(form_status);

    form_status = FlashMessage::Error(String::from("Connection Error"));
    print_flash_message(form_status);
}

fn print_flash_message(m: FlashMessage) {
    match m {
        FlashMessage::Success =>
            println!("Form Submitted correctly"),
        FlashMessage::Warning { category, message} =>
            println!("Warning: {} - {}", category, message),
        FlashMessage::Error(msg) =>
            println!("Error: {}", msg)
    }
}